package com.authine.cloudpivot.aspect;


import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

import java.util.Arrays;


/**
 * 部门查询用户过滤处理AOP
 * */
@Aspect
@Component
@Slf4j
public class filerUserProcessAspect {



    @Pointcut("execution(* com.authine.cloudpivot.web.api.controller.orgnization.DepartmentController.listUsers(..)) ")
    public void filerUserProcess() {
        log.debug("部门查询用户过滤处理！");
    }


    //环绕
    @Around(value = "filerUserProcess()" )
    public Object filerUserProcessDoc(ProceedingJoinPoint point) throws Throwable {
        log.debug("部门查询用户过滤处理！：部门查询用户过滤处理环绕通知开始执行....");
        log.info(Arrays.toString(point.getArgs()));

        //访问目标方法的参数并修改
        Object[] args = point.getArgs();
        try {
            if (args != null && args.length > 0) {
                args[3]="";
            }

        } catch (Exception e) {
           log.error("修改查询用户过滤信息失败：",e);
        }

        return point.proceed(args);
    }

}
